<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>我的京东_订单列表</h1><hr/>


<c:forEach items="${list}" var="order">
<div>
用户名称:${sessionScope.user.username}</br>
	订单号:${order.id}</br>
订单金额:¥${order.money}</br>
支付状态: <c:if test="${order.paystate == 0 }">
<font color="red">未支付</font>
	<a href="javascript:;" onclick="delOrderById('${order.id}',this)">删除订单</a>
	<a href="${pageContext.request.contextPath }/order/PaySerlvet?orderid=${order.id}">在线支付</a>
</c:if>
<c:if test="${order.paystate != 0}">
<font color="blue">已支付</font>
	<a href="javascript:;" onclick="updateOrderById('${order.id}',this)">删除订单</a>
</c:if>


	</br>
收货地址:${order.receinfo}</br>
下单时间:${order.add_time}</br>

<table border="1" cellspacing="0" cellpadding="10" align="center" width="95%">
	<tr>
		<th>缩略图</th>
		<th>商品名称</th>
		<th>商品种类</th>
		<th>商品单价</th>
		<th>购买数量</th>
		<th>总价</th>
	</tr>

	<c:forEach items="${order.items }" var="item">
		<tr>
			<td> <a href="${pageContext.request.contextPath}/prodInfo?id=${item.prod_id}">
				<img alt="xx" src="${applicationScope.pic_url}${item.product.imgurls}" width="120"/>
			</a></td>
			<td>${item.product.name }</td>
			<td>${item.product.type }</td>
			<td>${item.product.price }</td>
			<td>${item.buynum}</td>
			<td>¥${item.product.price * item.buynum }</td>
		</tr>
	</c:forEach>
</table>
<hr/>
<br/>
</div>

</c:forEach>

</body>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.12.4.js"></script>
<script type="text/javascript">

	function delOrderById(id,obj) {

		var flag = confirm("您确定要删除该订单吗？");
		if(flag){
			$.post("${pageContext.request.contextPath}/order/delOrderById",{"id":id},function (result) {
				if(result.code == 200){
					$(obj).parent().remove();
					alert("删除成功!");
				}else{
					alert("删除失败!");
				}
			},"json");

		}


	}

	function updateOrderById(id,obj) {

		var flag = confirm("您确定要删除该订单吗？");
		if(flag){
			$.post("${pageContext.request.contextPath}/order/updateOrderById",{"id":id},function (result) {
				if(result.code == 200){
					$(obj).parent().remove();
					alert("删除成功!");
				}
			},"json");

		}


	}
</script>
</html>